/*============================================================================*/
/*                   CONTINENTAL AUTOMOTIVE SYSTEMS                           */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* name:            APPWheel.c
* version:         1.1
* created_by:      Rodrigo Casados
* date_created:    June 7 2013
*=============================================================================*/
/* DESCRIPTION : Source file to implement main function.                      */
/*============================================================================*/
/* FUNCTION COMMENT : Implements entry point (main function) and other        */
/* application stuff.                                                         */
/*                                                                            */
/*============================================================================*/
/*                               OBJECT HISTORY                               */
/*============================================================================*/
/*  REVISION |   DATE      |                               |      AUTHOR      */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*  1.1      | 7/June/2013 |                               | Rodrigo Casados */
/* Initial version for the Smart Car Race 2010 contest using Freescale        */
/* Bolero micro.                                                              */
/*============================================================================*/


#include "APPWipers.h"



void SM_WIPER(E_SM_WIPER e_sm_wiper);

void SM_WIPER(E_SM_WIPER e_sm_wiper)
{
	switch(e_sm_wiper)
	{
		case INIT_WIPER:
		{
			WIPER_Init();
			break;
		}
		case WIPER_POSITION_OFF:
		{
			WIPER_SetWipePos(1);
			break;
		}
		case WIPER_POSITION_SLOW:
		{
			WIPER_SetWipePos(2);
			break;
		}
		case WIPER_POSITION_FAST:
		{
			WIPER_SetWipePos(3);
			break;
		}
		case WIPER_POSITION_FFAST:
		{
			WIPER_SetWipePos(4);
			break;
		}
		default:
			break;
	}
}

void Wiper_AutoPos(void)
{
	if (SENSOR_GetSensValue()==0x3FF)
	{
		SM_WIPER(WIPER_POSITION_FFAST);	
	}
	else if(SENSOR_GetSensValue()>=0x1FF)
	{
		SM_WIPER(WIPER_POSITION_FAST);	
	}
	else  if(SENSOR_GetSensValue()>=0x000)
	{
		SM_WIPER(WIPER_POSITION_SLOW);
	}
}
